<template>
  <section>
    <el-dialog
      title="办结"
      :visible.sync="open"
      width="500px"
      append-to-body
      @close="cancel"
      custom-class="completed-mode"
    >
      <Form
        :formData="formData"
        :rulesData="rulesData"
        :formBtns="formBtns"
        @handleSubmit="handleSubmit"
      />
    </el-dialog>
  </section>
</template>

<script>
import { Rule } from "@/utils/rule.js";
import Form from "@/components/form/index.vue";
import { vendorAuditComplete } from "@/api/collect/task/index";
export default {
  components: {
    Form,
  },
  props: {
    row: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      open: true,
      opinionSheet: [],
      formData: [
        {
          prop: "isReverseDocument",
          type: "radio",
          options: [
            {
              label: "是",
              value: true,
            },
            {
              label: "否",
              value: false,
            },
          ],
          label: "是否返件",
          value: true,
        },
        {
          prop: "inspectionConclusion",
          type: "input",
          label: "检查结论",
          placeholder: "请输入检查结论",
        },
        {
          prop: "comprehensiveConclusion",
          type: "input",
          label: "综合评定结论",
          placeholder: "请输入综合评定结论",
        },
        {
          prop: "fileList",
          type: "uploadFile",
          label: "上传资料",
          limit: 1,
          value: [],
          onChange: (data, obj) => {
            this.opinionSheet = data;
          },
        },
      ],
      formBtns: [
        //表单按钮
        {
          type: "primary",
          label: "保存",
          isVerify: true,
        },
        {
          label: "返回",
          click: () => {
            this.$emit("onBack", "isCompleted");
          },
        },
      ],

      rulesData: {
        acceptNo: [Rule.checkDataNull("请输入下一节点审核", "blur")],
      },
    };
  },

  mounted() {},
  methods: {
    //保存
    handleSubmit(data) {
      vendorAuditComplete({ ...data, id: this.row.id }).then((response) => {
        this.Message("办结成功");
        this.$emit("onSuccess", "isCompleted");
      });
    },
    // 关闭模态框
    cancel() {
      this.$emit("onBack", "isCompleted");
    },
  },
};
</script>

<style lang="scss">
@import "../../../assets/styles/collect.scss";
.completed-mode {
  .el-dialog__body {
    padding: 30px 20px 15px;
  }
  .form {
    margin-bottom: 0;
    .el-form-item {
      width: 100%;
      .el-form-item__label {
        width: 100px !important;
      }
      .el-form-item__content {
        margin-left: 100px !important;
      }
      &:last-child {
        margin-bottom: 0 !important;
      }
    }
  }
}
</style>
